package org.ricks.net.handler;

import app.controller.UserController;
import org.ricks.asm.reflectasm.MethodAccess;
import org.ricks.common.Context;
import org.ricks.dispatch.Dispatcher;
import org.ricks.ioc.AppContext;
import org.ricks.ioc.Message;
import org.ricks.net.AioSession;
import org.ricks.net.StateMachineEnum;

/**
 * @author chenwei
 * @Description:默认消息处理器
 * 目前方面asm动态生成class switch(cmd) case ....  case ....
 * todo 调整为asm 反射 和 直接调用区别不大。
 * @date 2022/12/2913:29
 */
public class DefaultHandler extends AbstractMessageProcessor<Message>{

    @Override
    public void process0(AioSession session, Message msg) {
        MethodAccess access = MethodAccess.get(UserController.class);
        int index = access.getIndex("test",Context.class);
        Object t = AppContext.getBean(UserController.class);
        access.invoke(t,index,new Context(session,msg));
//        Dispatcher.dispatcher(new Context(session,msg));
    }

    @Override
    public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) {

    }
}
